import AsyncStorage from "@react-native-async-storage/async-storage";

class Storage {
    async setStorage(key:string , value:string){
        try {
            await AsyncStorage.setItem(key, value)
        } catch (err) {
            console.log(err);
        }
    }
    //从本地缓存中读取置顶name对应的内容
	async getStorage(key:string) {
		let data: string | null;
		try {
			data = await AsyncStorage.getItem(key);
            return data;
		} catch (e) {
			console.log(e);
		}
	}

	//从本地缓存中移出指定key
	async removeStorage(key:string) {
		try {
		    await AsyncStorage.removeItem(key);
		} catch (e) {
			console.log(e);
		}
	}
    //清除本地数据缓存
	async clearCache(){
		try{
			await AsyncStorage.clear()
		}catch(e){
			console.log(e)
		}
	}
}

export default new Storage()